package model;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;


@XmlRootElement(name = "building")
public class Building extends Link implements Serializable
{
	private static final long serialVersionUID = 226309820205718752L;

	private static int i = 0;
	
	@XmlAttribute
	private String id = "";
	
	@XmlAttribute
	private String name = "";
	
	@XmlAttribute
	private String description = "";
	
	@XmlAttribute
	private String address = "";
	
	@XmlElement(name = "lectureRoom")
	private ArrayList<LectureRoom> lectureRooms = new ArrayList<LectureRoom>();
	
	public Building() {}
	
	public Building(String name, String description, String address)
	{
		i++;
		this.id = i + "";
		this.name = name;
		this.description = description;
		this.address = address;
	}
	
	public String toString()
	{
		String out = "\n";
		for (int i = 0; i < lectureRooms.size(); i++)
		{
			out += lectureRooms.get(i) + "\n";
		}
		return "Building id(" + id + ") -> Name: " + name + " | Description: " + description + " | Address: " + address + out;
	}
	
	public LectureRoom createLectureRoom(String name, String capacity, String type, String unit)
	{
		LectureRoom lectureRoom = new LectureRoom(name, capacity, type, unit);
		lectureRooms.add(lectureRoom);
		return lectureRoom;
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getName()
	{
		return name;
	}

	public String getDescription()
	{
		return description;
	}

	public String getAddress()
	{
		return address;
	}

	public ArrayList<LectureRoom> getLectureRooms()
	{
		return lectureRooms;
	}
}
